/* 
 * Search for a Range
 * For example, Given[5,7,7,8,8,10] and target value 8, return [3, 4]
 */

#include "../func.h"

vector<int> searchRange(vector<int> &nums, int target) {
    int l = distance(nums.begin(), lower_bound(nums.begin(), nums.end(), target));
    int u = distance(nums.begin(), prev(upper_bound(nums.begin(), nums.end(), target)));

    if (nums[l] != target)
        return vector<int> {-1, -1};
    else
        return vector<int> {l, u};
}